<?php
namespace app\go\controller;


class toController extends \app\base\controller\BaseController {
	


  public function yiqifa(){
  	  $id=$this->arg('id');
      if(!is_numeric($id)){ exit('error');}
	  include CONFIG_PATH . 'apiset.php';
	   $token= new \ZhiCms\ext\weixin;
	   //$zhuan= new \framework\ext\Zhuan;
	 $url="http://o.yiqifa.com/servlet/interface?method=yiqifa.product.detail.get&app_key=".$api['app_key']."&app_secret=".$api['app_secret']."&id=".$id."&yiqifalink=1&encoding=UTF-8";
	$ret=obj("api/Api")->object_array(json_decode($token->http($url),true));

	 $url=$ret['result']["moblieYqfShortUrl"];
     if(!$ret['result']["moblieYqfShortUrl"]){
	$url=$ret['result']['item']["mobileProductUrl"];   
    }
    $this->redirect($url);  
	  

  }
  
    public function url(){
  	  $id=$this->arg('id');
      if(!is_numeric($id)){ exit('error');}
	  $token= new \ZhiCms\ext\weixin;
	  include CONFIG_PATH . 'apiset.php';
	   $wheres[]="`id` ='{$id}'";
	   $goods=obj("api/Apidata")->Data_Select("goods",$wheres);
	   
	  if($goods['content']!=null|| $goods['content'] !=""){
	  $url="https://c.duomai.com/track.php?site_id=".$api['siteid']."&euid=".$id."&t=".$goods['couponUrl'];	
	  $this->redirect($url); 
	  }else{
	   //$zhuan= new \framework\ext\Zhuan;
	 $url="http://o.yiqifa.com/servlet/interface?method=yiqifa.product.detail.get&app_key=".$api['app_key']."&app_secret=".$api['app_secret']."&id=".$id."&yiqifalink=1&encoding=UTF-8";
	$ret=obj("api/Api")->object_array(json_decode($token->http($url),true));

	 $url=$ret['result']["moblieYqfShortUrl"];
     if(!$ret['result']["moblieYqfShortUrl"]){
	$url=$ret['result']['item']["mobileProductUrl"];   
    }
    $this->redirect($url);    
	  }
	  

  }

}